//
//  JSLLoanDetialScrollView.m
//  JingleSpeedLoan
//
//  Created by 宋质彬 on 2018/8/1.
//  Copyright © 2018年 宋质彬. All rights reserved.
//

#import "JSLLoanDetialScrollView.h"
#import "JSLLoanDetialTotalCell.h"

#import "ActionSheetPicker.h"

@interface JSLLoanDetialScrollView ()<UITableViewDelegate,UITableViewDataSource,loanDetialTotalCellDeleagate>
@property (nonatomic , weak) UIImageView *creditCardImage;
@property (nonatomic , strong) UIView *headerBackView;
@property (nonatomic , weak) UIImageView *headImageView;
@property (nonatomic , weak) UILabel *nameLab;
@property (nonatomic , weak) UILabel *rateLab;
@property (nonatomic , weak) UILabel *applyLab;
@property (nonatomic , weak) UIView *lineView;
@property (nonatomic , weak) UILabel *limitMoneyLab;
@property (nonatomic , weak) UILabel *limitDayLab;
@property (nonatomic , weak) UILabel *limitRateLab;

@property (nonatomic , strong) NSArray *textArray;
@property (nonatomic , weak) UIView *middleBackView;
@property (nonatomic , weak) UILabel *moneyTextLab;
@property (nonatomic , weak) UITextField *moneyTextField;
@property (nonatomic , weak) UIView *moneyLineView;
@property (nonatomic , weak) UITableView *moneyTableView;
@property (nonatomic , strong) NSMutableArray *totolArray;
@property (nonatomic , weak)  UIButton *applayButton;


@property (nonatomic , weak) UIView *footerBackView;

@property (nonatomic , strong) NSDictionary *info;

@property (nonatomic , strong) NSMutableArray *dateArray;

@property (nonatomic , strong) NSArray *appleyTiaoJianArray;
@property (nonatomic , strong) NSArray *xinYongTieShiArray;
@property (nonatomic , strong) NSMutableArray *shenHeXiJieArray;

@property (nonatomic , weak) UILabel *applyTJLabel;
@property (nonatomic , weak) UILabel *XYZXLabel;
@property (nonatomic , weak) UILabel *SHHKLabel;
@property (nonatomic , weak) UIView *colorView1;
@property (nonatomic , weak) UIView *colorView2;
@property (nonatomic , weak) UIView *colorView3;

@property (nonatomic , assign) CGSize labelSize;
@property (nonatomic , assign) CGSize labelSize1;
@property (nonatomic , assign) CGSize labelSize2;



@end
@implementation JSLLoanDetialScrollView

- (NSMutableArray *)totolArray {
    if (_totolArray == nil) {
        _totolArray = [[NSMutableArray alloc] init];
    }
    return _totolArray;
}
- (NSMutableArray *)dateArray {
    if (_dateArray == nil) {
        _dateArray = [[NSMutableArray alloc] init];
    }
    return _dateArray;
}
- (NSMutableArray *)shenHeXiJieArray {
    if (_shenHeXiJieArray == nil) {
        _shenHeXiJieArray = [[NSMutableArray alloc] init];
    }
    return _shenHeXiJieArray;
}
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = BACKGROUND_COLOR;
        [self configView];
    
    }
    return self;
}

#pragma mark - loanDetialTotalCellDeleagate
- (void)clickArrowButtion{
    [self selectCycleDate];
}
- (void)selectCycleDate{

    
    NSMutableArray *dateArray = [[NSMutableArray alloc] init];
    
    for (NSDictionary *info in self.dateArray) {
        [dateArray addObject:info[@"dateStr"]];
    }
    
    [ActionSheetStringPicker showPickerWithTitle:@"期限选择"
                                            rows:dateArray
                                initialSelection:0
                                       doneBlock:^(ActionSheetStringPicker *picker, NSInteger selectedIndex, id selectedValue) {
                                           
                                           NSLog(@"%ld - %@",(long)selectedIndex, selectedValue);
                                           
                                            [self selectMoneyDate:self.dateArray[selectedIndex]];
                                           
                                       } cancelBlock:^(ActionSheetStringPicker *picker) {
                                           
                                           NSLog(@"cancel");
                                           
                                       } origin:self];

}

-(void)configLoanDetial:(NSDictionary *)info {
    self.info = info;
    [self.headImageView sd_setImageWithURL:[NSURL URLWithString:info[@"productLogo"]] placeholderImage:nil];
    
    self.nameLab.text = info[@"productName"];
    
    self.rateLab.text = [NSString stringWithFormat:@"利息最低：%@%@",info[@"dayRate"],@"%"];
    NSRange rangeRate = [self.rateLab.text rangeOfString:[NSString stringWithFormat:@"%@%@",info[@"dayRate"],@"%"]];
    [JSLKitFactory attributedText:self.rateLab font:self.rateLab.font range:rangeRate color:RGBCOLOR(252,91,53)];
    
    
    self.applyLab.text = [NSString stringWithFormat:@"申请成功：%@人",info[@"applyNum"]];
    
    NSRange range = [self.applyLab.text rangeOfString:[NSString stringWithFormat:@"%@人",info[@"applyNum"]]];
    [JSLKitFactory attributedText:self.applyLab font:self.applyLab.font range:range color:RGBCOLOR(252,91,53)];
    
 
    
    NSString *AmountFanWie = [NSString stringWithFormat:@"%@~%@",info[@"lowAmount"],info[@"highAmount"]];
    

    NSString *cycleTime = [NSString stringWithFormat:@"%@天",info[@"lowCycle"]];
    
    NSString *rateCanKao = [NSString stringWithFormat:@"%@%@",info[@"dayRate"],@"%"];
    
    self.textArray = @[AmountFanWie,cycleTime,rateCanKao];
    
    self.moneyTextField.text = [NSString stringWithFormat:@"%@",info[@"lowAmount"]];
    
    
    [self configMoneyDate:[self.info[@"lowCycle"] integerValue] highCycle:[self.info[@"highCycle"] integerValue]];
    
    
    self.appleyTiaoJianArray = [info[@"applyCondition"] componentsSeparatedByString:@","];
    
    NSString *creditStr = @"";
    if ([info[@"productCredit"] boolValue]) {
        creditStr = @"上征信";
    }else {
        creditStr = @"不上征信";
        
    }
    self.xinYongTieShiArray = @[creditStr];
    
   
    
    
    [self configFooterView:info];
    
    
    [self configFrame];
}


- (void)configFooterView:(NSDictionary *)info {
    
    
    for (UIView *view in self.footerBackView.subviews) {
        [view removeFromSuperview];
        
    }
    
    NSArray *facePeopleArray = [info[@"audienceGroup"] componentsSeparatedByString:@","];
    for (NSString *audienceGroup in facePeopleArray) {
        if ([audienceGroup isEqualToString: @"1"]) {
            [self.shenHeXiJieArray addObject:@"上班族"];
        }else if ([audienceGroup isEqualToString: @"2"]) {
            [self.shenHeXiJieArray addObject:@"学生党"];
        }else if ([audienceGroup isEqualToString: @"3"]) {
            [self.shenHeXiJieArray addObject:@"逍遥客"];
        }else if ([audienceGroup isEqualToString: @"4"]) {
            [self.shenHeXiJieArray addObject:@"企业主"];
        }
    }
    
    self.colorView1 = [JSLKitFactory jsl_viewWithFrame:CGRectZero backgroundColor:[@"#65b3ff" hexStringToColor] superView:self.footerBackView];
    
    self.colorView2 = [JSLKitFactory jsl_viewWithFrame:CGRectZero backgroundColor:[@"#65b3ff" hexStringToColor] superView:self.footerBackView];
    
    self.colorView3 = [JSLKitFactory jsl_viewWithFrame:CGRectZero backgroundColor:[@"#65b3ff" hexStringToColor] superView:self.footerBackView];
    

    self.applyTJLabel = [JSLKitFactory jsl_labelWithFrame:CGRectZero text:@"申请条件" font:LIGHT_FONT(12) textColor:[@"#666666" hexStringToColor] textAlignment:NSTextAlignmentLeft SuperView:self.footerBackView];
    
    self.colorView1.frame = CGRectMake(40*AutoSizeScaleXX, 20*AutoSizeScaleXX, 2*AutoSizeScaleXX, 10*AutoSizeScaleXX);
    
    CGSize applyTJSize = [self.applyTJLabel.text sizeWithAttributes:@{NSFontAttributeName : self.applyTJLabel.font}];
    self.applyTJLabel.frame = CGRectMake(self.colorView1.right+10*AutoSizeScaleXX, 0, applyTJSize.width, applyTJSize.height);
    self.applyTJLabel.centerY = self.colorView1.centerY;
    
    for (NSInteger i = 0 ; i <self.appleyTiaoJianArray.count; i ++) {
        UILabel *label = [JSLKitFactory jsl_labelWithFrame:CGRectZero text:self.appleyTiaoJianArray[i] font:LIGHT_FONT(10) textColor:[@"#4ea6fa" hexStringToColor] textAlignment:NSTextAlignmentCenter SuperView:self.footerBackView];
        label.text = self.appleyTiaoJianArray[i];
        CGSize labSize = [label.text sizeWithAttributes:@{NSFontAttributeName : label.font}];
        label.frame = CGRectMake(self.applyTJLabel.left +(self.labelSize.width +8*AutoSizeScaleXX +10*AutoSizeScaleXX)*i,self.applyTJLabel.bottom+ 14*AutoSizeScaleXX , labSize.width+8*AutoSizeScaleXX, labSize.height +8*AutoSizeScaleXX);
        self.labelSize = labSize;
        label.backgroundColor = [UIColor colorWithRed:78.0f/255.0f green:166.0f/255.0f blue:250.0f/255.0f alpha:0.5f];
        label.layer.cornerRadius = 2;
        label.layer.borderColor = [@"4ea6fa" hexStringToColor].CGColor;
        label.layer.borderWidth = 0.5;
        label.layer.masksToBounds = YES;
        
    }
    
    self.colorView2.frame = CGRectMake(self.colorView1.left, self.colorView1.bottom +68.5*AutoSizeScaleXX, self.colorView1.width, self.colorView1.height);
    
    
    self.XYZXLabel = [JSLKitFactory jsl_labelWithFrame:CGRectZero text:@"信用贴士" font:LIGHT_FONT(12) textColor:[@"#666666" hexStringToColor] textAlignment:NSTextAlignmentLeft SuperView:self.footerBackView];
    self.XYZXLabel.frame = CGRectMake(self.applyTJLabel.left, self.colorView2.top, self.applyTJLabel.width, self.applyTJLabel.height);
    self.XYZXLabel.centerY = self.colorView2.centerY;
    
    
    for (NSInteger i = 0 ; i <self.xinYongTieShiArray.count; i ++) {
        UILabel *label = [JSLKitFactory jsl_labelWithFrame:CGRectZero text:self.xinYongTieShiArray[i] font:LIGHT_FONT(10) textColor:[@"#4ea6fa" hexStringToColor] textAlignment:NSTextAlignmentCenter SuperView:self.footerBackView];
        CGSize labSize = [label.text sizeWithAttributes:@{NSFontAttributeName : label.font}];
        label.frame = CGRectMake(self.XYZXLabel.left +(self.labelSize1.width +8*AutoSizeScaleXX +10*AutoSizeScaleXX)*i,self.XYZXLabel.bottom+ 14*AutoSizeScaleXX , labSize.width+8*AutoSizeScaleXX, labSize.height +8*AutoSizeScaleXX);
        self.labelSize1 = labSize;
        label.backgroundColor = [UIColor colorWithRed:78.0f/255.0f green:166.0f/255.0f blue:250.0f/255.0f alpha:0.5f];
        label.layer.cornerRadius = 2;
        label.layer.borderColor = [@"4ea6fa" hexStringToColor].CGColor;
        label.layer.borderWidth = 0.5;
        label.layer.masksToBounds = YES;
        
    }
    
    self.colorView3.frame = CGRectMake(self.colorView2.left, self.colorView2.bottom +68.5*AutoSizeScaleXX, self.colorView2.width, self.colorView2.height);
    
    self.SHHKLabel = [JSLKitFactory jsl_labelWithFrame:CGRectZero text:@"审核还款细节" font:LIGHT_FONT(12) textColor:[@"#666666" hexStringToColor] textAlignment:NSTextAlignmentLeft SuperView:self.footerBackView];
    
    CGSize jjSize = [self.SHHKLabel.text sizeWithAttributes:@{NSFontAttributeName : self.SHHKLabel.font}];
    self.SHHKLabel.frame = CGRectMake(self.XYZXLabel.left, self.colorView3.top, jjSize.width,jjSize.height);
    self.SHHKLabel.centerY = self.colorView3.centerY;
    

    NSString *kindStr = [self.shenHeXiJieArray componentsJoinedByString:@"，"];
    NSRange rang = NSMakeRange(kindStr.length -1, 1);
    kindStr = [kindStr stringByReplacingCharactersInRange:rang withString:@""];
    
    NSArray *arr = @[
  @{@"title" : @"面向人群：",@"scr" : kindStr},
  @{@"title" : @"审核方式：",@"scr" : info[@"auditMethod"]},
  @{@"title" : @"到账方式：",@"scr" : info[@"reachType"]},
  @{@"title" : @"实际到账：",@"scr" : info[@"actualAccount"]},
  @{@"title" : @"还款途径：",@"scr" : info[@"repaymentWay"]}];
    
    for (NSInteger i = 0; i < arr.count; i ++) {
        
        NSDictionary *info = arr[i];
        UILabel *poepleKind = [JSLKitFactory jsl_labelWithFrame:CGRectZero text:info[@"title"] font:LIGHT_FONT(11) textColor:[@"#999999" hexStringToColor] textAlignment:NSTextAlignmentLeft SuperView:self.footerBackView];
        UILabel *label = [JSLKitFactory jsl_labelWithFrame:CGRectZero text:info[@"scr"] font:LIGHT_FONT(11) textColor:[@"#666666" hexStringToColor] textAlignment:NSTextAlignmentCenter SuperView:self.footerBackView];
        CGSize labSize = [label.text sizeWithAttributes:@{NSFontAttributeName : label.font}];
        
        CGSize kindSize = [poepleKind.text sizeWithAttributes:@{NSFontAttributeName : poepleKind.font}];
        poepleKind.frame = CGRectMake(self.SHHKLabel.left, self.SHHKLabel.bottom +15*AutoSizeScaleXX+(15*AutoSizeScaleXX +labSize.height)*i, kindSize.width, kindSize.height);
        
        
        label.frame = CGRectMake(poepleKind.right +5*AutoSizeScaleXX,poepleKind.top , labSize.width, labSize.height);
        label.centerY = poepleKind.centerY;
    }
    
}



- (void)configMoneyDate:(NSInteger)lowCycle highCycle:(NSInteger)highCycle {
//    NSInteger highCycle = [self.info[@"highCycle"] integerValue];
//    NSInteger lowCycle = [self.info[@"lowCycle"] integerValue];

    if (lowCycle<30) {
        [self.dateArray addObject:@{@"dateStr":[NSString stringWithFormat:@"%ld天",(long)lowCycle],@"date":[NSString stringWithFormat:@"%ld",(long)lowCycle]}];
        
        if (highCycle<30) {
            
            for (NSInteger i =0; i <(highCycle-lowCycle); i ++) {
               [self.dateArray addObject:@{@"dateStr":[NSString stringWithFormat:@"%ld天",((long)lowCycle +1)],@"date":[NSString stringWithFormat:@"%ld",((long)lowCycle +1)]}];
            }
            
        }else {
            NSInteger amout = highCycle/30;
            for (NSInteger i =0; i <amout; i ++) {
                [self.dateArray addObject:@{@"dateStr":[NSString stringWithFormat:@"%ld个月",(1+i)],@"date":[NSString stringWithFormat:@"%ld",(1+i)]}];
            }
        }
    }else if (lowCycle>30 ||lowCycle==30) {
        NSInteger lowAmount = lowCycle/30;
        NSInteger hightAmout = highCycle/30;
        for (NSInteger i =0; i <=(hightAmout - lowAmount); i ++) {
            [self.dateArray addObject:@{@"dateStr":[NSString stringWithFormat:@"%ld个月",(lowAmount+i)],@"date":[NSString stringWithFormat:@"%ld",(lowAmount+i)]}];
        }
    }
    
    NSLog(@"%@",self.dateArray);
    
    [self selectMoneyDate:[self.dateArray firstObject]];
    
}
- (void)selectMoneyDate:(NSDictionary *)dateInfo{
    
    [self.totolArray removeAllObjects];

    CGFloat lixiValue = 0;
    if ([dateInfo[@"dateStr"] hasSuffix:@"月"]) {
        lixiValue = [dateInfo[@"date"] integerValue] *[self.info[@"dayRate"] floatValue]*0.01 *[self.moneyTextField.text floatValue] *30;
    }else {
        lixiValue = [dateInfo[@"date"] integerValue] *[self.info[@"dayRate"] floatValue] *[self.moneyTextField.text floatValue] ;
        
    }
    
    
    CGFloat allAmount = [self.moneyTextField.text floatValue] +lixiValue;
    
    CGFloat daoZAmount = [self.moneyTextField.text floatValue] -lixiValue;
    
    
    [self.totolArray addObject:@{@"title":@"期限",@"subSrc":dateInfo[@"dateStr"]}];
    [self.totolArray addObject:@{@"title":@"利息",@"subSrc":[NSString stringWithFormat:@"%.2f",lixiValue]}];
    [self.totolArray addObject:@{@"title":@"息费合计",@"subSrc":[NSString stringWithFormat:@"%.2f",allAmount]}];
    [self.totolArray addObject:@{@"title":@"到账金额",@"subSrc":[NSString stringWithFormat:@"%.2f",daoZAmount]}];
    
    [self.totolArray addObject:@{@"title":@"还款总额",@"subSrc":[NSString stringWithFormat:@"%.2f",allAmount]}];

 
    NSLog(@"%@",self.totolArray);
    
    [self.moneyTableView reloadData];
    
    
    
}

- (void)layoutSubviews{
    [super layoutSubviews];
    [self configFrame];
}

- (void)configFrame {
    
    self.headerBackView.frame = CGRectMake(10*AutoSizeScaleXX, 10 *AutoSizeScaleXX, SCREEN_WIDTH-10 *AutoSizeScaleXX*2, 109*AutoSizeScaleXX);
    
    [JSLKitFactory roundedRect:self.headerBackView.bounds cornerRadius:1];
    
    self.headImageView.frame = CGRectMake(10 *AutoSizeScaleXX, 15*AutoSizeScaleXX, 30*AutoSizeScaleXX, 30*AutoSizeScaleXX);
    
    CGSize nameSize = [self.nameLab.text sizeWithAttributes:@{NSFontAttributeName : self.nameLab.font}];
    self.nameLab.frame = CGRectMake(self.headImageView.right +7*AutoSizeScaleXX, self.headImageView.top-2, nameSize.width, nameSize.height);
    
    CGSize rateSize = [self.rateLab.text sizeWithAttributes:@{NSFontAttributeName : self.rateLab.font}];
    
    self.rateLab.frame = CGRectMake(self.nameLab.left, self.nameLab.bottom +2*AutoSizeScaleXX, rateSize.width, rateSize.height);
    
    CGSize ApplaySize = [self.applyLab.text sizeWithAttributes:@{NSFontAttributeName : self.applyLab.font}];
    self.applyLab.frame = CGRectMake(self.rateLab.right+10*AutoSizeScaleXX, self.rateLab.top, ApplaySize.width, self.rateLab.height);
    
    for (NSInteger i = 0; i < 3; i ++) {
        UILabel *textLab = [self.headerBackView viewWithTag:100 +i];
        textLab.frame = CGRectMake(0 +(self.headerBackView.width/3)*i, self.applyLab.bottom+19*AutoSizeScaleXX, self.headerBackView.width/3, 20);
        
        UILabel *contenLab = [self.headerBackView viewWithTag:1000 +i];
        contenLab.frame = CGRectMake(0 +(self.headerBackView.width/3)*i, textLab.bottom+2*AutoSizeScaleXX, self.headerBackView.width/3, 20);
        contenLab.text = self.textArray[i];
        
    }
    
    self.middleBackView.frame = CGRectMake(self.headerBackView.left, self.headerBackView.bottom+10*AutoSizeScaleXX, self.headerBackView.width, 326*AutoSizeScaleXX +32*AutoSizeScaleXX);
    
    CGSize moneySize = [self.moneyTextLab.text sizeWithAttributes:@{NSFontAttributeName : self.moneyTextLab.font}];
    self.moneyTextLab.frame = CGRectMake(0, 20 *AutoSizeScaleXX, self.middleBackView.width, moneySize.height);
    
    CGSize moneyTextSize = [@"27777" sizeWithAttributes:@{NSFontAttributeName : MEDIUM_FONT(27)}];
    self.moneyTextField.frame = CGRectMake(40*AutoSizeScaleXX, self.moneyTextLab.bottom +5*AutoSizeScaleXX, self.middleBackView.width - 40*AutoSizeScaleXX*2, moneyTextSize.height +20*AutoSizeScaleXX);
    
    self.moneyLineView.frame = CGRectMake(self.moneyTextField.left, self.moneyTextField.bottom, self.moneyTextField.width, 1);
    
    self.moneyTableView.frame = CGRectMake(0, self.moneyLineView.bottom +15*AutoSizeScaleXX, self.middleBackView.width,  self.middleBackView.height - CGRectGetMaxY(self.moneyLineView.frame)-15*AutoSizeScaleXX -60*AutoSizeScaleXX);
    
    self.applayButton.frame = CGRectMake(40*AutoSizeScaleXX, self.moneyTableView.bottom, self.middleBackView.width -40*AutoSizeScaleXX*2, 40*AutoSizeScaleXX);
    
    self.applayButton.layer.mask = [JSLKitFactory roundedRect:self.applayButton.bounds cornerRadius:2];
    
    self.footerBackView.frame = CGRectMake(self.middleBackView.left, self.middleBackView.bottom+10*AutoSizeScaleXX, self.middleBackView.width, 320*AutoSizeScaleXX +50*AutoSizeScaleXX);
    
    
    
  
    
    
    
}

- (void)configView {
    self.headerBackView = [JSLKitFactory jsl_viewWithFrame:CGRectZero backgroundColor:[UIColor whiteColor] superView:self];
    
    self.headImageView = [JSLKitFactory jsl_imageViewWithFrame:CGRectZero imageName:@"" superView:self.headerBackView];
    
  
    self.nameLab = [JSLKitFactory jsl_labelWithFrame:CGRectZero text:@"dadg" font:MEDIUM_FONT(14) textColor:[@"#4a4a4a" hexStringToColor] textAlignment:NSTextAlignmentLeft SuperView:self.headerBackView];
    
    self.rateLab = [JSLKitFactory jsl_labelWithFrame:CGRectZero text:@"利率最低：0.00%" font:LIGHT_FONT(10) textColor:[@"#9b9b9b" hexStringToColor] textAlignment:NSTextAlignmentLeft SuperView:self.headerBackView];
    
    self.applyLab = [JSLKitFactory jsl_labelWithFrame:CGRectZero text:@"利率最低：0.00%" font:LIGHT_FONT(10) textColor:[@"#9b9b9b" hexStringToColor] textAlignment:NSTextAlignmentLeft SuperView:self.headerBackView];
    
    self.lineView = [JSLKitFactory jsl_viewWithFrame:CGRectZero backgroundColor:[@"#d8d8d8" hexStringToColor] superView:self.headerBackView];
    
    NSArray *textArray = @[@"额度范围",@"期限",@"参考利率"];
    NSArray *contentArray = @[@"--",@"--天",@"0.00%"];
    for (NSInteger i = 0; i <textArray.count ; i ++) {
        UILabel *textlab =  [JSLKitFactory jsl_labelWithFrame:CGRectZero text:textArray[i] font:LIGHT_FONT(10) textColor:[@"#9b9b9b" hexStringToColor] textAlignment:NSTextAlignmentCenter SuperView:self.headerBackView];
        textlab.tag = i +100;
        
        UILabel *contenLab = [JSLKitFactory jsl_labelWithFrame:CGRectZero text:contentArray[i] font:LIGHT_FONT(12) textColor:[@"#4a4a4a" hexStringToColor] textAlignment:NSTextAlignmentCenter SuperView:self.headerBackView];
        contenLab.tag = i +1000;
    }
    
    self.middleBackView = [JSLKitFactory jsl_viewWithFrame:CGRectZero backgroundColor:[UIColor whiteColor] superView:self];
    
    self.moneyTextLab = [JSLKitFactory jsl_labelWithFrame:CGRectZero text:@"金额" font:REGULAR_FONT(16) textColor:RGBCOLOR(153,153,153) textAlignment:NSTextAlignmentCenter SuperView:self.middleBackView];
    
    self.moneyTextField = [JSLKitFactory jsl_textFieldWithFrame:CGRectZero WithPlaceholder:@"" withDelegat:self superView:self.middleBackView textAlignment:NSTextAlignmentCenter textFont:MEDIUM_FONT(27) textColol:RGBCOLOR(252,91,53)];
    
    self.moneyLineView = [JSLKitFactory jsl_viewWithFrame:CGRectZero backgroundColor:RGBCOLOR(237,237,237) superView:self.middleBackView];
    
    
    UITableView *moneyTableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
    moneyTableView.separatorStyle = UITableViewCellSelectionStyleNone;
    moneyTableView.scrollEnabled = YES;
    moneyTableView.rowHeight = 32 *AutoSizeScaleXX;
    moneyTableView.backgroundColor = [UIColor whiteColor];
    moneyTableView.delegate = self;
    moneyTableView.dataSource = self;
    moneyTableView.showsVerticalScrollIndicator = NO;
    [self.middleBackView addSubview:moneyTableView];
    self.moneyTableView = moneyTableView;
    
    
    self.applayButton = [JSLKitFactory jsl_titleButtonWithFrame:CGRectZero superView:self.middleBackView font:LIGHT_FONT(14) titleColor:[UIColor whiteColor] backgroundColor:[@"#4ea6fa" hexStringToColor] title:@"立即申请" target:self action:@selector(applyButtonAction:)];
    
    
    
    self.footerBackView = [JSLKitFactory jsl_viewWithFrame:CGRectZero backgroundColor:[UIColor whiteColor] superView:self];
    
//    self.colorView1 = [JSLKitFactory jsl_viewWithFrame:CGRectZero backgroundColor:[@"#65b3ff" hexStringToColor] superView:self.footerBackView];
//
//    self.colorView2 = [JSLKitFactory jsl_viewWithFrame:CGRectZero backgroundColor:[@"#65b3ff" hexStringToColor] superView:self.footerBackView];
//
//    self.colorView3 = [JSLKitFactory jsl_viewWithFrame:CGRectZero backgroundColor:[@"#65b3ff" hexStringToColor] superView:self.footerBackView];
//
//
//
//    self.applyTJLabel = [JSLKitFactory jsl_labelWithFrame:CGRectZero text:@"申请条件" font:LIGHT_FONT(12) textColor:[@"#666666" hexStringToColor] textAlignment:NSTextAlignmentLeft SuperView:self.footerBackView];
//
//    self.XYZXLabel = [JSLKitFactory jsl_labelWithFrame:CGRectZero text:@"信用贴士" font:LIGHT_FONT(12) textColor:[@"#666666" hexStringToColor] textAlignment:NSTextAlignmentLeft SuperView:self.footerBackView];
//
//
//    self.SHHKLabel = [JSLKitFactory jsl_labelWithFrame:CGRectZero text:@"审核还款细节" font:LIGHT_FONT(12) textColor:[@"#666666" hexStringToColor] textAlignment:NSTextAlignmentLeft SuperView:self.footerBackView];
//
//
   
    
    

    
    

}

- (void)applyButtonAction:(UIButton *)sender {
    
   
    NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
    parameters[@"productId"] = self.info[@"productId"];
    parameters[@"productName"] = self.info[@"productId"];
    
    parameters[@"applyAmount"] = self.moneyTextField.text;
    parameters[@"repaymentAmount"] = [self.totolArray lastObject][@"subSrc"];
    
    if ([self.loanDetialScrollViewDelegat respondsToSelector:@selector(clickNowApplyButtion:)]) {
        [self.loanDetialScrollViewDelegat clickNowApplyButtion:parameters];
    }
    
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.totolArray.count;
    
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    JSLLoanDetialTotalCell *cell = [JSLLoanDetialTotalCell cellWithTableView:tableView];
    cell.info = self.totolArray[indexPath.row];
    cell.deleagete = self;
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
}
@end
